package com.xctz.niceman.developer;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v7.app.AppCompatActivity;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import org.xutils.common.Callback;
import org.xutils.http.RequestParams;
import org.xutils.view.annotation.ContentView;
import org.xutils.x;

import java.util.Objects;

/**
 * Created by Administrator on 2016/8/3.
 *
 * xutils 的网络请求
 */
@ContentView(R.layout.fragemnt1_layout)
public class Fragment1 extends Fragment {
    private Activity act ;


    @Override
    public void onAttach(Context context) {
        super.onAttach(context);
        act = (Activity) context ;
    }

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
    }

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        return x.view().inject(this,inflater,container); //绑定xutils的事件
    }

    @Override
    public void onActivityCreated(@Nullable Bundle savedInstanceState) {
        super.onActivityCreated(savedInstanceState);
    }

    public void getHttp(RequestParams params){
        x.http().get(params, new Callback.CacheCallback<Object>() {
            @Override
            public void onSuccess(Object o) {

            }

            @Override
            public void onError(Throwable throwable, boolean b) {

            }

            @Override
            public void onCancelled(CancelledException e) {

            }

            @Override
            public void onFinished() {

            }

            @Override
            public boolean onCache(Object o) {
                return false;
            }
        });

    }
}
